var userNameId = "userName";
var userAddressId = "userAddr";
var userMobileId = "userMobile";
var orderResNameId = "orderResName";
var orderNumId = "orderNum";
var orderResAddressId = "orderResAddress";
var orderResContactNumId = "orderResContactNum";
var orderArrivalId = "orderArrival";
var orderResContactId = "orderResContactId";

var orderResInfo = "orderResInfo";

function getUserInformation(name,address,mobileNumber){
	var userName = "<strong>"+name+"</strong>\'s Personal Details"+"<hr>";
	var userAddress = "<strong>Your Address</strong>:&nbsp&nbsp&nbsp"+address;
	var userMobile = "<strong>Your Contact Number</strong>: &nbsp&nbsp (+65)&nbsp"+mobileNumber;

	// <div class = "container"><h3>username</h3></div>
	var userInfo = getNormalContainerBegin(userNameId)+"<h3>"+userName+"</h3>"+getContainerEnd();

	// <div id = "userAddr" class = "container"><p>username</p></div>
	userInfo += getUserContainerBegin(userAddressId)+"<p>"+userAddress+"</p>"+getContainerEnd();

	// <div id = "userAddr" class = "container"><p>username</p></div>
	userInfo += getUserContainerBegin(userMobileId)+"<p>"+userMobile+"</p>"+getContainerEnd();

	return userInfo;
}

// orders is an JSON including information of the form
// {"orderNum":data, "res_name":data, "arrivalTime":data, "res_address":data,"res_contact":data}
function getUserOrders(orders){
	var resultHtml = "";
	var len = orders.length;
	
	for(var i=0;i<len;i++){
		resultHtml += (getOneOrder(orders[i]));
	}
	return resultHtml;
}

function getOneOrder(order){
	var address = order.res_address;
	var res = "<div class = \"orders container userOrderSingle\"><div class = \"transbox\">";
	res += getUserContainerBegin("orders") + "<p>" + "<strong>Your Orders</strong>: " + "</p>" + getContainerEnd() ;;
	res += getOrderContainerBegin(orderResNameId) + "<p>&nbsp&nbspRestaurant:&nbsp" + order.res_name +"</p>"+ getContainerEnd();
	res += getOrderContainerBegin(orderNumId) + "<p>Order Number:&nbsp"+order.orderNum +"</p>"+getContainerEnd();
	res += getOrderContainerBegin(orderArrivalId)+ "<p>Arrival Time: &nbsp"+order.arrivalTime +"</p>"+ getContainerEnd();
	res += getOrderContainerBegin(orderResAddressId) + "<p>Address: &nbsp" + order.res_address + "</p>" +getContainerEnd()+"</div>";
	res += "<button class = \"btn btn-primary pull-left edit-order\" id=\""+order.orderNum+"\" value=\""+order.orderNum+"\" onclick = \"editOrder(this)\"><strong> Change Time</strong> </button>";
	res += "<button class = \"btn btn-primary pull-right cancel-order\" id=\""+order.orderNum+"\" value=\""+order.orderNum+"\" onclick = \"cancellOrder(this)\"><strong> Cancel Order</strong> </button>";
	res += "<div id=\"datePicker_"+order.orderNum+"\"></div>";

	res+="</div> <br><br>";

	return res;
}

// function getOneOrder(order){
// 	var res = "<div class = \"orders container userOrderSingle\"><p><span>";
// 	res += "<strong>Your Orders</strong>: "+"<br />";
// 	res += "Restaurant: " + order.res_name+"<br />";
// 	res += "Order Number:&nbsp"+order.orderNum+"<br />";
// 	res += "Arrival Time: &nbsp"+order.arrivalTime+"<br />";
// 	res += "Address: &nbsp" + order.res_address +"<br />";
// 	res += "Contact: &nbsp" + order.res_contact + "</span></p>";
// 	res += "<button class = \"btn btn-primary pull-right cancel-order\" id=\""+order.orderNum+"\" value=\""+order.orderNum+"\" onclick = \"cancellOrder(this)\"><strong> Cancel Order</strong> </button>";
// 	res+="</div> <br><br>";
// 	return res;
// }

function getNormalContainerBegin(){
	return "<div class = \"container\">";
}

function getOrderContainerBegin(idString){
	return "<div id = \""+idString+"\" class = \"row container "+orderResInfo+"\">";
}

function getUserContainerBegin(idString){
	return "<div id = \""+idString+"\" class = \"row container\">";
}

function getContainerEnd(){
	return "</div>";
}